package com.richapp.launcher.serialport.gateway;


public class ControlInstructionMessage {
	
	private String boxCpuId;
	private String deviceId;
	private String deviceNumer;
    private String way;
	private String key;

	//指令内容
	private String hexInstruction;
	//指令标识
	private String instructionFlag;
	//指令失败次数
	private int failCount = 0;
	//指令发送结果
	private String instructionResult;
	//指令执行结果
	private String instructionDoResult;
	//指令开始时间
	private long startTime = 0;
	//指令结束之间
	private long stopTime = 0;
	//设置超时时间
	private int timeOut = GatewaytConstant.INSTRUCTION_SEND_SLEEP_TIME;
	//指令结果
	private String resultData = "";

	
	public ControlInstructionMessage(String boxCpuId,String deviceId,String deviceNumber,String way) {
		this.boxCpuId = boxCpuId;
		this.deviceId = deviceId;
		this.deviceNumer = deviceNumber;
        this.way = way;
	}

	public ControlInstructionMessage(String boxCpuId,String deviceId,String deviceNumber) {
		this.boxCpuId = boxCpuId;
		this.deviceId = deviceId;
		this.deviceNumer = deviceNumber;
	}

	public String getHexInstruction() {
		return hexInstruction;
	}

	public void setHexInstruction(String hexInstruction) {
		hexInstruction = hexInstruction.toUpperCase();
		this.hexInstruction = hexInstruction;
	}

	public synchronized String getInstructionFlag() {
		return instructionFlag;
	}

	public synchronized void setInstructionFlag(String instructionFlag) {
		this.instructionFlag = instructionFlag;
	}

	public synchronized int getFailCount() {
		return failCount;
	}

	public synchronized void setFailCount(int failCount) {
		this.failCount = failCount;
	}

	public synchronized String getInstructionResult() {
		return instructionResult;
	}

	public synchronized void setInstructionResult(String instructionResult) {
		this.instructionResult = instructionResult;
	}

	public synchronized String getInstructionDoResult() {
		return instructionDoResult;
	}

	public synchronized void setInstructionDoResult(String instructionDoResult) {
		this.instructionDoResult = instructionDoResult;
	}

	public synchronized long getStartTime() {
		return startTime;
	}

	public synchronized void setStartTime(long startTime) {
		this.startTime = startTime;
	}

	public synchronized long getStopTime() {
		return stopTime;
	}

	public synchronized void setStopTime(long stopTime) {
		this.stopTime = stopTime;
	}

	public int getTimeOut() {
		if(GatewaytConstant.INSTRUCTION_FLAG_ADD_ALL.equals(this.instructionFlag)){
			timeOut = GatewaytConstant.INSTRUCTION_MIND_ADD_SLEEP_TIME;
		}else if(GatewaytConstant.INSTRUCTION_FLAG_INFRARED_STUDY.equals(this.instructionFlag)){
			timeOut = GatewaytConstant.INSTRUCTION_STUDY_TIME_OUT;
		}else{
			timeOut = GatewaytConstant.INSTRUCTION_SEND_SLEEP_TIME;
		}
		return timeOut;
	}

	public String getBoxCpuId() {
		return boxCpuId;
	}

	public void setBoxCpuId(String boxCpuId) {
		this.boxCpuId = boxCpuId;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public String getDeviceNumer() {
		return deviceNumer;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public void setDeviceNumer(String deviceNumer) {
		this.deviceNumer = deviceNumer;
	}

    public String getWay() {
        return way;
    }

    public void setWay(String way) {
        this.way = way;
    }

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getResultData() {
		return resultData;
	}

	public void setResultData(String resultData) {
		this.resultData = resultData;
	}

	@Override
	public String toString() {
		return "ControlInstructionMessage{" +
				"boxCpuId='" + boxCpuId + '\'' +
				", deviceId='" + deviceId + '\'' +
				", deviceNumer='" + deviceNumer + '\'' +
				", way='" + way + '\'' +
				", hexInstruction='" + hexInstruction + '\'' +
				", instructionFlag='" + instructionFlag + '\'' +
				", failCount=" + failCount +
				", instructionResult='" + instructionResult + '\'' +
				", instructionDoResult='" + instructionDoResult + '\'' +
				", startTime=" + startTime +
				", stopTime=" + stopTime +
				", timeOut=" + timeOut +
				'}';
	}
}
